package com.peas.platform.module.icims;

import com.peas.platform.module.icims.base.sys.dto.AttachmentDto;
import com.peas.platform.module.icims.base.sys.service.AttachmentService;
import lombok.SneakyThrows;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.zip.ZipOutputStream;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AttachmentDownloadTestCase {

    @Resource
    private AttachmentService attachmentService;

    @SneakyThrows
    @Test
    public void downloads() {
        List<Long> ids = Arrays.asList(1687839294527422464L, 1687839526556319744L);
        List<AttachmentDto> list = attachmentService.listByIds(ids);
        ZipOutputStream zip = new ZipOutputStream(Files.newOutputStream(Paths.get("/Users/caizhaohui/Desktop/1.zip")));
        attachmentService.zipFiles(list, zip);
    }

}
